package com.bilibili.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bilibili.dto.CommentInfo;
import com.bilibili.entity.CommonResult;
import com.bilibili.entity.Page;
import com.bilibili.service.CommentService;
import com.bilibili.service.impl.CommentServiceImpl;

@WebServlet("/commentAllSix.do")
public class CommentAllSixServlet extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("application/json;charset=UTF-8");
    	CommentService c = new CommentServiceImpl();
    	CommentInfo ci = new CommentInfo();
    	ci.setState(-1);
    	ci.setUserId(-1);
    	int pageNum = 1,pageSize = 5;
    	try {
    		pageNum = Integer.parseInt(request.getParameter("pageNum"));
    	}catch (Exception e) {
			// TODO: handle exception
		}
    	Page<CommentInfo> cPage = c.selectAllCommentInfoB(ci,pageNum,pageSize);
    	CommonResult cr = new CommonResult();
    	cr.setCode(200);
    	cr.setData(cPage);
    	response.getWriter().write(cr.toJSONString());
	}
}
